﻿@model IEnumerable<SAB.Domain.Publication.PublicationType>
@{
    ViewBag.Title = "PublicationTypeSaveResultView";
}

<div class="row">
    <div class="col-md-12">
        <ol class="breadcrumb">
            <li>@Html.ActionLink("Home", "Index", "Home")</li>
            <li>@Html.ActionLink("Tipo publicación", "Search", "PublicationType")</li>
            <li class="active">Buscar</li>
        </ol>
    </div>
</div>


<div class="col-md-10">
    <div class="pull-right">
        <a href="@Url.Content("~/PublicationType/Create")" class="btn btn-primary">
            <i class="glyphicon glyphicon-plus"></i> Nuevo Tipo de Publicación
        </a>
    </div>
</div>
<br>

<div class="row">
    <div class="col-md-12 title">
        <h1>Búsqueda Tipo Publicación</h1>
    </div>
</div>

<div class="col-md-10">
    @if (TempData["message"] != null)
    {
        <div class="alert alert-success" role="alert">@TempData["message"]</div>
    }
    @if (TempData["alert"] != null)
    {
        <div class="alert alert-danger" role="alert">@TempData["alert"]</div>
    }

</div>

<div class="row">
    <form action="@Url.Action("SearchResult", "PublicationType")" method="post" id="PRS_SearchForm">
        <div class="col-md-10">
            <div class="form-group">
                <div class="row">
                    <div class="col-md-1">
                    </div>
                    <div class="col-md-2">
                        <label for="tipo">Código</label>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <input class="form-control" type="text" name="codigo" pattern="[0-9]*" title="Solo números" value="@ViewData["codigo"]" maxlength="10" />
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="row">
                    <div class="col-md-1">
                    </div>
                    <div class="col-md-2">
                        <label for="tipo">Nombre</label>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <input type="text" class="form-control" name="nombre" pattern="[A-Za-zá-ú\s]+" title="Solo letras y espacios" value="@ViewData["nombre"]" maxlength="50" />
                        </div>
                    </div>
                </div>
            </div>

            @if (ViewBag.pageIndex != null)
            {
                <input type="hidden" value="@ViewBag.pageIndex" name="pageIndex" id="PRS_pageIndex" class="form-control">
            }
            else
            {
                <input type="hidden" value="1" name="pageIndex" id="PRS_pageIndex">
            }
            <div class="col-md-9">
                <button type="submit" class="btn btn-primary pull-right" id="btnSearchResutlView">Buscar</button>
            </div>
        </div>
    </form>
</div>

<!---------- LISTA TIPO PUBLICACION ------------->

<div class="form-group">
    <div class="col-md-10">
        <div class="row">

            <table class="table-responsive table table-striped">
                <tr>
                    <th>Código</th>
                    <th>Nombre</th>
                    <th>Descripción</th>
                    <th></th>
                </tr>
                @foreach (var publicationType in Model) 
                {
                    <tr>
                        <td>@publicationType.Id</td>
                        <td>@publicationType.Name</td>
                        <td>@publicationType.Description</td>
                        <td>
                            <a href="@Url.Action("Detail", "PublicationType", new { id = publicationType.Id })"><i class="margin-right-icon glyphicon glyphicon-zoom-in"></i></a>
                            <a href="@Url.Action("Modify", "PublicationType", new { id = publicationType.Id })"><i class="margin-right-icon glyphicon glyphicon-pencil"></i></a>
                        </td>
                    </tr>
                }
            </table>

            <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
                <div class="modal-dialog">
                    <form action="@Url.Action("Delete", "PublicationType")" method="post">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                <h4 class="modal-title" id="myModalLabel">Confirmación</h4>
                            </div>
                            <div class="modal-body">
                                <div>
                                    <label class="control-label">
                                        ¿Estás seguro que quieres eliminar este Tipo de Publicación?
                                    </label>
                                </div>
                            </div>
                            <input type="hidden" name="element_id" class="deleteElementInput" value="0" />
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                                <button type="submit" class="btn btn-primary">Aceptar</button>
                            </div>

                        </div>
                    </form>
              </div>
          </div>

            @*----------------------------Paginacion---------------------------------*@

            <div class="col-md-12 col-md-offset-3 form-horizontal">
                <div class="form-group ">
                    <div>
                        <ul class="pagination">
                            <li><a id="PRS_btnFirst">Primero</a></li>
                            <li><a id="PRS_btnPrev">&laquo;</a></li>

                            <li>
                                @if (ViewBag.pageIndex != null)
                                {
                                    <span>@ViewBag.pageIndex</span>
                                }
                                else
                                {
                                    <span>1</span>
                                }
                            </li>
                            <li><a id="PRS_btnNext">&raquo;</a></li>
                            <li><a id="PRS_btnLast">Último</a></li>
                        </ul>
                    </div>
                    <label for="searchText" class="col-md-2">Ir a la página</label>
                    <div class="col-md-2">
                        <input type="text" class="form-control" id="PRS_pageIndexChange">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@section Scripts
{
    <script src="@Url.Content("~/Scripts/Publication.js")"></script>
}